import {createRouter, createWebHistory} from 'vue-router'
import NoticePage from "@/page/NoticePage.vue";
import AddArticlePage from "@/page/front/AddArticlePage.vue";
import notFoundPage from "@/views/404.vue";
import UserLoginPage from "@/page/UserLoginPage.vue";
import ACCESS_ENUM from "@/access/accessEnum.js";

const routes = [
    {path: '/', redirect: '/article'},
    {path: '/chat', component: () => import('../page/chat.vue')},
    {
        path: '/', component: () => import('../layout/FrontLayout.vue'),
        children: [
            {path: '/article/:id', component: () => import('../page/front/ArticleDeatilPage.vue')},
            {path: 'article', component: () => import('../page/front/ArticleListPage.vue')},
            {path: '/user/:userId/info',component: () => import('../page/front/UserInfoPage.vue')},
            {path: '/user/edit/info', component: () => import('../page/UserInfoPage.vue')},
        ]
    },
    {
        path: '/user/login',
        name: 'login',
        component: UserLoginPage
    },
    {
        path: '/manager', component: () => import('../layout/BaseLayout.vue'),
        meta: {
            access: ACCESS_ENUM.ADMIN,
        },
        children: [
            {path: 'home', name: '首页', component: NoticePage},
            {path: 'user', name: '用户信息', component: () => import('../page/admin/UserManagerPage.vue')},
            {path: 'UserInfo', name: '个人信息', component: () => import('../page/UserInfoPage.vue')},
            {path: 'updatePwd', name: '修改密码', component: () => import('../page/updatePwd.vue')},
            {path: 'notice', name: '公告管理', component: () => import('../page/admin/NoticeManagerPage.vue')},
            {path: 'article', name: '文章管理', component: () => import('../page/admin/ArticleManagerPage.vue')},
            {path: ':pathMatch(.*)*', name: 'notfound', component: () => import('../views/404.vue')}
        ]
    },
    {
        path: '/add_article',
        name: '创建图片',
        component: AddArticlePage,
    },
    {
        path: '/:pathMatch(.*)*',
        name: '404',
        component: notFoundPage
    }


]

const router = createRouter({
    history: createWebHistory(import.meta.env.BASE_URL),
    routes
})

export default router
